package com.example.springboot.mapper;

import com.example.springboot.entity.Score;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author author
 * @since 2022-04-14
 */
public interface ScoreMapper extends BaseMapper<Score> {

    @Select("select sum(score) from score where solution_id = #{solutionId}")
    Double getScoreSum(Integer solutionId);

    @Select("select count(score) from score where solution_id = #{solutionId}")
    Integer getScoreCount(Integer solutionId);

    @Update("update score set score = #{score} where user_id = #{user_id} and solution_id = #{solution_id}")
    boolean updateScore(Integer user_id,Integer solution_id,Double score);

}
